/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package LinkRetriever;

import General.Globals;
import java.util.ArrayList;

/**
 *
 * @author Manuel
 */
public class ListManager {

    private ArrayList<String> projectLinks;
    private ArrayList<String> visited;
    private ArrayList<String> toVisit;

    public ListManager(){
        projectLinks = new ArrayList();
        visited = new ArrayList();
        toVisit = new ArrayList();
    }

    public boolean insertIfNotVisited(String link){
        boolean added = false;
        if(!visited.contains(link) && !toVisit.contains(link)){
            toVisit.add(link);
            added = true;
        }
        return added;
    }

    public String visitNext(){
        String link = toVisit.get(0);
        toVisit.remove(0);
        visited.add(link);
        return link;
    }

    public boolean addProjectLink(String link){
        if(!projectLinks.contains(link)){
            projectLinks.add(link);
            return true;
        }
        return false;
    }

    public int getLinksLeft(){
        return toVisit.size();
    }

    public ArrayList<String> getProjectLinks() {
        return projectLinks;
    }

    public String getProjectLinksAsString(){
        String linksAsString ="";
        for(int i = 0;i<projectLinks.size();i++)
            linksAsString = linksAsString + projectLinks.get(i) + ";";
        return linksAsString;
    }

    public ArrayList<String> getToVisit() {
        return toVisit;
    }

    public ArrayList<String> getVisited() {
        return visited;
    }

    public int getNoOfProjects(){
        return projectLinks.size();
    }

    public void deleteAll() {
        visited.clear();
        toVisit.clear();
    }



}
